<template>
  <div class="dashboard-editor-container" :style="{height:height}">
    <!-- <github-corner class="github-corner" /> -->
    <div style="text-align: right">更新时间 : {{lastUpdateTime}}</div>
    <panel-group :titleObj="titleObj" @handleSetLineChartData="handleSetLineChartData"/>


    <el-row :gutter="24">

      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <raddar-chart v-if="isShow" :raddData="raddData"/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart v-if="isShow" :pieData="pieData"/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <!-- <bar-chart :data="barData"/> -->
          <pie-chart1 v-if="isShow" :pieData1="pieData1"/>
        </div>
      </el-col>

    </el-row>


    <el-row :gutter="24">
      <el-col :xs="16" :sm="16" :lg="16">
        <div class="chart-wrapper">

          <line-chart :chart-data="lineData"/>
        </div>
      </el-col>
      <el-col :xs="8" :sm="8" :lg="8">
        <div class="chart-wrapper" style="padding-left:0;padding-right:0;padding-top:0">
          <!-- <pie-chart /> -->
          <box-card :boxData="pregress"/>
        </div>
      </el-col>

    </el-row>

    <el-row :gutter="24">
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart2 v-if="isShow" :pieData2="pieData2"/>
        </div>
      </el-col>

      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <pie-chart3 v-if="isShow" :pieData3="pieData3"/>
        </div>
      </el-col>
      <el-col :xs="24" :sm="24" :lg="8">
        <div class="chart-wrapper">
          <funnel v-if="isShow" :funnel-data="funnelData"/>
        </div>
      </el-col>
    </el-row>
    <el-row :gutter="24">
      <el-col :xs="8" :sm="8" :lg="8">
        <div class="chart-wrapper">
          <pie-chart4 v-if="isShow" :pieData4="pieData4"/>
        </div>
      </el-col>
      <el-col :xs="16" :sm="16" :lg="16">
        <div class="chart-wrapper">
          <table-data :table-data="tableData"/>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import GithubCorner from '@/components/GithubCorner'
  import PanelGroup from './components/PanelGroup'
  import LineChart from './components/LineChart'
  import RaddarChart from './components/RaddarChart'
  import PieChart from './components/PieChart'
  import PieChart1 from './components/PieChart1'
  import PieChart2 from './components/PieChart2'
  import PieChart3 from './components/PieChart3'
  import PieChart4 from './components/PieChart4'
  import BarChart from './components/BarChart'
  import TransactionTable from './components/TransactionTable'
  import TodoList from './components/TodoList'
  import BoxCard from './components/BoxCard'
  import Funnel from './components/Funnel'
  import TableData from './components/TableData'
  import vueSeamlessScroll from 'vue-seamless-scroll'

  import {
    getAllData
  } from "@/api/retrieval.js"

  const lineChartData = {
    newVisitis: {
      expectedData: [100, 120, 161, 134, 105, 160, 165],
      actualData: [120, 82, 91, 154, 162, 140, 145]
    },
    messages: {
      expectedData: [200, 192, 120, 144, 160, 130, 140],
      actualData: [180, 160, 151, 106, 145, 150, 130]
    },
    purchases: {
      expectedData: [80, 100, 121, 104, 105, 90, 100],
      actualData: [120, 90, 100, 138, 142, 130, 130]
    },
    shoppings: {
      expectedData: [130, 140, 141, 142, 145, 150, 160],
      actualData: [120, 82, 91, 154, 162, 140, 130]
    }
  }

  export default {
    name: 'DashboardAdmin',
    components: {
      TableData,
      GithubCorner,
      PanelGroup,
      LineChart,
      RaddarChart,
      PieChart,
      PieChart1,
      PieChart2,
      PieChart3,
      PieChart4,
      BarChart,
      TransactionTable,
      TodoList,
      BoxCard,
      Funnel,
      vueSeamlessScroll
    },
    computed: {


      optionLeft() {
        return {
          direction: 2,
          limitMoveNum: 2,
          step: 0.5
        }
      }
    },

    data() {
      return {
        lineChartData: lineChartData.newVisitis,
        height: window.innerHeight - 50 + "px",

        newsList: [{}, {}, {}],
        lastUpdateTime:null,
        raddData: [],
        pieData: [],
        pieData1: [],
        pieData2: [],
        pieData3: [],
        pieData4: [],
        funnelData: [],
        lineData: [],
        pregress: {},
        titleObj: {},
        tableData: [],
        isShow: false

      }
    },
    mounted() {
      window.onresize = () => {
        this.height = window.innerHeight - 50
      }


      getAllData().then(res => {
        this.isShow = true
        let obj = {

          total: res.data.total,
          effectiveTotal: res.data.effectiveTotal,
          effectiveInventionTotal: res.data.effectiveInventionTotal,
          highScoreTotal: res.data.highScoreTotal,
          grantTotal: res.data.grantTotal,
          currentYearGrantTotal: res.data.currentYearGrantTotal
        }
        this.lastUpdateTime =  res.data.lastUpdateTime,
        this.titleObj = obj
        this.raddData = res.data.firstBoard
        this.pieData = res.data.twoBoard
        this.pieData1 = res.data.threeBoard

        this.lineData = res.data.fourBoard
        this.pregress = res.data.fiveBoard

        this.pieData2 = res.data.sixBoard;
        this.pieData3 = res.data.sevenBoard;

        this.funnelData = res.data.eightBoard;
        this.pieData4 = res.data.nineBoard;
        this.tableData = res.data.tenBoard;
      })
    },
    methods: {
      handleSetLineChartData(type) {
      }
    }
  }
</script>

<style lang="scss" scoped>
  .dashboard-editor-container {
    overflow: auto;
    padding: 24px;
    background-color: rgb(240, 242, 245);
    position: relative;

    .seamless-warp2 {
      overflow: hidden;
      height: 400px;
      width: 100%;

      .box {

        width: 100%;

        .item {
          display: inline-block;
          width: 600px;
          height: 400px;
          // background-color: red;
          padding: 25px;
          margin-left: 50px;
        }

      }
    }

    .github-corner {
      position: absolute;
      top: 0px;
      border: 0;
      right: 0;
    }

    .chart-wrapper {
      background: #fff;
      padding: 16px 16px 0;
      margin-bottom: 24px;
    }
  }

  @media (max-width: 1024px) {
    .chart-wrapper {
      padding: 8px;
    }
  }
</style>
